/**
 * \file map.c
 **/
#include "map.h"
#include <stdio.h>

int main(void)
{
  RValue map = r_map_new();
  RValue int1 = r_value_from_int32(1);
  RValue int2 = r_value_from_int32(2);
  RValue int3 = r_value_from_int32(3);

  r_map_set(map, int1, int2);
  r_map_set(map, int2, int2);
  r_map_set(map, int3, int1);
  r_map_set(map, int2, int3);

  RValue value;
  assert(r_map_get(map, int1, &value));
  assert(r_value_equal(value, int2));
  assert(r_map_get(map, int2, &value));
  assert(r_value_equal(value, int3));
  assert(r_map_get(map, int3, &value));
  assert(r_value_equal(value, int1));

  #define N 10000
  RValue values[N];
  int i;
  for (i = 0; i < N; i++){
    values[i] = r_value_from_int32(i);
    r_map_set(map, values[i], int1);
  }

  int n = 0, e = 0;
  for (i = 0; i < map.val_map->size; i++){
    if (map.val_map->buckets[i].key.type == R_VALUE_SPEC){
      e++;
      printf("*");
    } else {
      n++;
      printf(" ");
    }
  }
  printf("\nn = %d\ne = %d\n", n, e);

  return 0;
}
